<template>
  <div>
    <div class="tab-title">
<!--      <span class="tab_tit">申请订单明细</span>-->
    </div>
    <el-table border v-loading="loading" :data="dataList" @selection-change="handleSelectionChange" ref="table"
              :max-height="tableMaxHeight">
      <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
      <el-table-column label="订单编号" align="center" prop="projectNo"/>
      <el-table-column label="客户名称" align="center" prop="apply.customerName"/>
      <el-table-column label="发票金额" align="center" prop="amount"/>
      <el-table-column label="备注" align="center" prop="remark"/>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getList"/>
  </div>
</template>

<script>
import {deleteAction, getAction} from '@/api/manage'

export default {
  name: "GoodsInvoiceApplyDetailListSection",
  components: {
  },
  props: {
    applyId: {
      type: String,
      default: "",
    },
  },
  watch: {
    applyId: {
      handler(newVal, oldVal) {
        this.queryParams.applyId = newVal;
        if (newVal) {
          this.getList();
        }
      },
      immediate: true
    },
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 发票申请明细表格数据
      dataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        applyId: null,
        amount: null,
        projectId: null,
        projectNo: null,
      },
      url: {
        list: '/goodsInvoiceApplyDetail/goodsInvoiceApplyDetail/list',
        remove: '/goodsInvoiceApplyDetail/goodsInvoiceApplyDetail/',
        export: '/goodsInvoiceApplyDetail/goodsInvoiceApplyDetail/export',
      },
      tableMaxHeight: window.innerHeight - 320,
    };
  },
  created() {
    this.getList();
    window.addEventListener('resize', this.getTableHeight);
  },
  destroyed() {
    window.removeEventListener('resize', this.getTableHeight)
  },
  methods: {
    /** 查询发票申请明细列表 */
    getList() {
      this.loading = true;
      getAction(this.url.list, this.queryParams).then(response => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getTableHeight() {
      this.tableHeight = window.innerHeight - 320
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },

  }
};
</script>
